import request from "@/utils/request.js";

// 注册用户信息
export const userRegisterService = registerData => {
    const param = new URLSearchParams();
    for (let key in registerData) {
        param.append(key, registerData[key]);
    }
    return request.post("/user/register", param);
};

// 登录
export const userLoginService = registerData => {
    const params = new URLSearchParams();
    for (let key in registerData) {
        params.append(key, registerData[key]);
    }
    return request.post("/user/login", params);
};

// 获取用户详细信息
export const getDetailService = () => {
    return request.get("/user/userInfo");
};

// 保存修改的用户信息
export const updateUserService = userInfo => {
    return request.put("/user/update", userInfo);
};

// 更新用户头像
export const updateAvatar = imgUrl => {
    const params = new URLSearchParams();
    params.append("avatarUrl", imgUrl);
    return request.patch("/user/updateAvatar", params);
};

// 更改用户密码
export const updatePwd = formData => {
    return request.patch("/user/updatePwd", formData);
};
